package algo3c2g15.vista;

import javax.swing.*;

import algo3c2g15.domain.*;

public class VentanaConstrucciones extends JDialog{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static VentanaConstrucciones instance = null;
	private static PanelConstrucciones panel;
	
	public VentanaConstrucciones(Humano humano){
		super();
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setTitle(humano.getRegionActual().getNombre());
		setBounds(400, 100, 300, 250);
		setResizable(false);
		setAlwaysOnTop(true);
		
		panel = new PanelConstrucciones( humano );
		add(panel);
		
		setVisible(true);
	}

	public static VentanaConstrucciones getInstance(){
		return instance;
	}
	
	public static void createVentanaConstrucciones(Humano humano){
		if (instance != null) {
			humano.getRegionActual().deleteObserver( panel );
			instance.dispose();
		}
		instance = new VentanaConstrucciones( humano );
	}
	
	public static void cerrar(){
		if (instance != null) {
			panel.getCivil().getRegionActual().deleteObserver( panel );
			instance.dispose();
		}
	}

}
